namespace SilverSea.Untilities
{
    using System;
    using System.Threading;
    using System.Windows.Forms;

    public class Splash
    {
        public static frmSplash frm;
        public static Thread thread;

        public static void Hide()
        {
            Thread.Sleep(100);
            try
            {
                frm.Invoke(new MethodInvoker(frm.Close));
                frm = null;
                thread = null;
            }
            catch
            {
            }
        }

        public static void Show()
        {
            thread = new Thread(new ThreadStart(Splash.WorkerThread));
            thread.IsBackground = true;
            thread.Start();
            Application.DoEvents();
        }

        public static void WorkerThread()
        {
            frm = new frmSplash();
            Application.Run(frm);
        }

        public static string Status
        {
            set
            {
                if (frm != null)
                {
                    frm.Status = value;
                }
            }
        }
    }
}

